﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace MidSoft.Web.Model_T_SYS_USER
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				#warning 代码生成提示：显示页面,请检查确认该语句是否正确
				ShowInfo();
			}
		}
			
	private void ShowInfo()
	{
		MidSoft.BLL.BLL_T_SYS_USER bll=new MidSoft.BLL.BLL_T_SYS_USER();
		MidSoft.Model.Model_T_SYS_USER model=bll.GetModel();
		this.txtSYS_USER_ID.Text=model.SYS_USER_ID;
		this.txtADDRESS.Text=model.ADDRESS;
		this.txtBIRTHDAY.Text=model.BIRTHDAY.ToString();
		this.txtGROUP_ID.Text=model.GROUP_ID;
		this.txtGROUP_NAME.Text=model.GROUP_NAME;
		this.txtLOGIN_NAME.Text=model.LOGIN_NAME;
		this.txtE_MAIL.Text=model.E_MAIL;
		this.txtNAME.Text=model.NAME;
		this.txtPASSWORD.Text=model.PASSWORD;
		this.txtPASSWORD_ANSWER.Text=model.PASSWORD_ANSWER;
		this.txtPWD_QUESTION.Text=model.PWD_QUESTION;
		this.txtPOSTAL_CODE.Text=model.POSTAL_CODE;
		this.txtSEX.Text=model.SEX;
		this.txtTELEPHONE.Text=model.TELEPHONE;
		this.txtCREATE_TIME.Text=model.CREATE_TIME.ToString();
		this.txtCREATOR_ID.Text=model.CREATOR_ID;
		this.txtCREATOR_NAME.Text=model.CREATOR_NAME;
		this.txtUPDATE_TIME.Text=model.UPDATE_TIME.ToString();
		this.txtUPDATOR_ID.Text=model.UPDATOR_ID;
		this.txtUPDATOR_NAME.Text=model.UPDATOR_NAME;
		this.txtID.Text=model.ID.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtSYS_USER_ID.Text.Trim().Length==0)
			{
				strErr+="ID不能为空！\\n";	
			}
			if(this.txtADDRESS.Text.Trim().Length==0)
			{
				strErr+="地址不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtBIRTHDAY.Text))
			{
				strErr+="生日格式错误！\\n";	
			}
			if(this.txtGROUP_ID.Text.Trim().Length==0)
			{
				strErr+="组ID不能为空！\\n";	
			}
			if(this.txtGROUP_NAME.Text.Trim().Length==0)
			{
				strErr+="组名不能为空！\\n";	
			}
			if(this.txtLOGIN_NAME.Text.Trim().Length==0)
			{
				strErr+="登录名不能为空！\\n";	
			}
			if(this.txtE_MAIL.Text.Trim().Length==0)
			{
				strErr+="E_MAIL。不能为空！\\n";	
			}
			if(this.txtNAME.Text.Trim().Length==0)
			{
				strErr+="姓名不能为空！\\n";	
			}
			if(this.txtPASSWORD.Text.Trim().Length==0)
			{
				strErr+="密码不能为空！\\n";	
			}
			if(this.txtPASSWORD_ANSWER.Text.Trim().Length==0)
			{
				strErr+="密码回答不能为空！\\n";	
			}
			if(this.txtPWD_QUESTION.Text.Trim().Length==0)
			{
				strErr+="密码问题不能为空！\\n";	
			}
			if(this.txtPOSTAL_CODE.Text.Trim().Length==0)
			{
				strErr+="邮编不能为空！\\n";	
			}
			if(this.txtSEX.Text.Trim().Length==0)
			{
				strErr+="性别不能为空！\\n";	
			}
			if(this.txtTELEPHONE.Text.Trim().Length==0)
			{
				strErr+="电话不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCREATE_TIME.Text))
			{
				strErr+="创建时间格式错误！\\n";	
			}
			if(this.txtCREATOR_ID.Text.Trim().Length==0)
			{
				strErr+="创建人ID不能为空！\\n";	
			}
			if(this.txtCREATOR_NAME.Text.Trim().Length==0)
			{
				strErr+="创建人不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUPDATE_TIME.Text))
			{
				strErr+="更新时间格式错误！\\n";	
			}
			if(this.txtUPDATOR_ID.Text.Trim().Length==0)
			{
				strErr+="更新人ID不能为空！\\n";	
			}
			if(this.txtUPDATOR_NAME.Text.Trim().Length==0)
			{
				strErr+="更新人不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtID.Text))
			{
				strErr+="原ID格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string SYS_USER_ID=this.txtSYS_USER_ID.Text;
			string ADDRESS=this.txtADDRESS.Text;
			DateTime BIRTHDAY=DateTime.Parse(this.txtBIRTHDAY.Text);
			string GROUP_ID=this.txtGROUP_ID.Text;
			string GROUP_NAME=this.txtGROUP_NAME.Text;
			string LOGIN_NAME=this.txtLOGIN_NAME.Text;
			string E_MAIL=this.txtE_MAIL.Text;
			string NAME=this.txtNAME.Text;
			string PASSWORD=this.txtPASSWORD.Text;
			string PASSWORD_ANSWER=this.txtPASSWORD_ANSWER.Text;
			string PWD_QUESTION=this.txtPWD_QUESTION.Text;
			string POSTAL_CODE=this.txtPOSTAL_CODE.Text;
			string SEX=this.txtSEX.Text;
			string TELEPHONE=this.txtTELEPHONE.Text;
			DateTime CREATE_TIME=DateTime.Parse(this.txtCREATE_TIME.Text);
			string CREATOR_ID=this.txtCREATOR_ID.Text;
			string CREATOR_NAME=this.txtCREATOR_NAME.Text;
			DateTime UPDATE_TIME=DateTime.Parse(this.txtUPDATE_TIME.Text);
			string UPDATOR_ID=this.txtUPDATOR_ID.Text;
			string UPDATOR_NAME=this.txtUPDATOR_NAME.Text;
			decimal ID=decimal.Parse(this.txtID.Text);


			MidSoft.Model.Model_T_SYS_USER model=new MidSoft.Model.Model_T_SYS_USER();
			model.SYS_USER_ID=SYS_USER_ID;
			model.ADDRESS=ADDRESS;
			model.BIRTHDAY=BIRTHDAY;
			model.GROUP_ID=GROUP_ID;
			model.GROUP_NAME=GROUP_NAME;
			model.LOGIN_NAME=LOGIN_NAME;
			model.E_MAIL=E_MAIL;
			model.NAME=NAME;
			model.PASSWORD=PASSWORD;
			model.PASSWORD_ANSWER=PASSWORD_ANSWER;
			model.PWD_QUESTION=PWD_QUESTION;
			model.POSTAL_CODE=POSTAL_CODE;
			model.SEX=SEX;
			model.TELEPHONE=TELEPHONE;
			model.CREATE_TIME=CREATE_TIME;
			model.CREATOR_ID=CREATOR_ID;
			model.CREATOR_NAME=CREATOR_NAME;
			model.UPDATE_TIME=UPDATE_TIME;
			model.UPDATOR_ID=UPDATOR_ID;
			model.UPDATOR_NAME=UPDATOR_NAME;
			model.ID=ID;

			MidSoft.BLL.BLL_T_SYS_USER bll=new MidSoft.BLL.BLL_T_SYS_USER();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
